/*
ID: guoxu1
PROG: numtri
LANG: C++
*/
#include <fstream>
using namespace std;

#define cin fin
#define cout fout

int main()
{
  ifstream fin( "numtri.in" );
  ofstream fout( "numtri.out" );

  int r = 0;
  cin >> r;
  
  int F[1000] = {0};
  for( int i = 1; i <= r; i++ )
  {
    for( int j = i; j > 0; j-- )
    {
      int n;
      cin >> n;
      F[j] = std::max( F[j] + n, F[j-1] + n );
    }
  }

  int max_plus = 0;
  for( int i = 1; i <= r; i++ )
  {
    if( max_plus < F[i] ) max_plus = F[i];
  }
  cout << max_plus << endl;
  return 0;
}
